﻿using System;
using System.Web;
using System.Data;

namespace AliCMS.Lib
{
    public class AdminUserControlBase : UserControl
    {
        public AdminUserControlBase(string pathInTemplate)
            : base(pathInTemplate)
        {
        }

        #region Properties
        protected string ContentLang
        {
            get
            {
                if (String.IsNullOrEmpty(_contentLang))
                {
                    if (String.IsNullOrEmpty(Request.QueryString["Lang"]))
                    {
                        HttpCookie cookie = Request.Cookies["DefaultContentLanguage"];
                        if (cookie == null)
                            _contentLang = Channel[AliCMS.SystemModule.Alias.Channel.Lang].ToString();
                        else
                            _contentLang = cookie.Value;
                    }
                    else
                    {
                        _contentLang = Request.QueryString["Lang"];
                    }
                }

                return _contentLang;
            }
        }
        protected string CurrentLanguage
        {
            get
            {
                DataRow[] rows = Manager.Languages.Select(AliCMS.SystemModule.Alias.Language.Ab + "='" + ContentLang + "'");
                return rows[0][AliCMS.SystemModule.Alias.Language.Name + PageLang].ToString();
            }
        }
        #endregion

        #region Fields
        private string _contentLang;
        #endregion
    }
}
